package com.leased.service.impl;

import com.leased.exception.DatabaseException;
import com.leased.mapper.manual.ICustomizedCarsLocationMapper;
import com.leased.request.cuser.CUserListRequest;
import com.leased.response.CarsLocationResponse;
import com.leased.service.CarsLocationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by shencx on 2017/8/4.
 */
@Service
public class CarsLocationServiceImpl implements CarsLocationService{

    Logger LOG = LoggerFactory.getLogger(CarsLocationServiceImpl.class);

    @Resource
    private ICustomizedCarsLocationMapper customizedCarsLocationMapper;

    /**
     * 获取车辆位置列表
     * @param cUserListRequest
     * @return
     * @throws DatabaseException
     */
    @Override
    public List<CarsLocationResponse> fetchCarsLocationList(CUserListRequest cUserListRequest) throws DatabaseException {
        try {
            if (cUserListRequest == null){
                LOG.error("fetchCarsLocationList 信息为空",cUserListRequest);
                return null;
            }
            List<CarsLocationResponse> list = customizedCarsLocationMapper.findCarsLocationList(cUserListRequest);
            return list;
        }  catch (Throwable e) {
            LOG.error("fetchCarsLocationList 发生异常",e,cUserListRequest);
            throw new DatabaseException(e.getMessage());
        }
    }
}
